<?php
//入口文件 定义常量
define('SYS',dirname(dirname(__FILE__)));
define('M',[
	'Ds'=>DIRECTORY_SEPARATOR,//换行符
	'IndexName'=>'index.php',//默认文件名
	'Suffix'=>'.html',//默认后缀
	'In'=>SYS.DIRECTORY_SEPARATOR,//系统目录
	'App'=>SYS.DIRECTORY_SEPARATOR.'M'.DIRECTORY_SEPARATOR,//程序目录
	'Mod'=>SYS.DIRECTORY_SEPARATOR.'M'.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR,
	
	'TemplateDir'=>'templates',//模板目录
	'TemplateType'=>'dir',
	'CacheDir'=>'cache',
	'ControllersDir'=>'controllers',
	'Public'=>'public',
	
	'RouterStart'=>true,//自定义路由
	'PostFilter'=>true,//过滤post
	'Debug'=>false,
	
	
	'mdb'=>[
		'database_type'		=>	'mysql',
		'database_name'		=>	'ucms',
		'server'			=>	'127.0.0.1',
		'username'			=>	'ucms',
		'password'			=>	'siGGASJfCBrcrwNM',
		'charset'			=>	'utf8',
		'port'				=>	3306,
		'prefix'			=>	'mtfy_'
	],
	
	'cache'=>[
		'start'			=>true,
		'type'          => 'redis',
		'pre'           => 'mtfy',
		'host'			=>'127.0.0.1',
		'port'			=>'6379',
		'dir'			=>'data'
	],
	'session'=>[
		'start'=>true,
		'type'=>'file',//session type  [file, memcache, redis]
		'host'=>'tcp://127.0.0.1:6379',//session host [memcache 11211 redis 6379]
		'dir'=>'session'
	],
	
	'tpl'=>[
		'tpltime'	=>0,
		'tplstart'	=>'#{',
		'tplend'	=>'}',
		'tplcachedir'=>'tpl'
	],
]);
//加载模块函数
function m($m){$fileUri=M['App'].M['Ds'].'models'.M['Ds'].$m.'.php';if(is_file($fileUri))include_once $fileUri;}m('func');
//执行路由
//如果开启自定义路由，则设定
if(M['RouterStart']){
	global $routes;
	$routes=[
		['uri'=>'/res','res'=>'/index/ces','domain'=>'','site'=>'','func'=>'defRouter1','data'=>''], 
		 //uri 匹配的规则 {字符串} [数字]  ,res 运行控制器, domain:绑定域名，site 绑定入口目录,	func 处理路由   data  附带数据
		['uri'=>'/','res'=>'/index/index','domain'=>'127.0.0.1','site'=>'','func'=>function($e){return [];}],
	];
	//路由可以是函数
	// $router=function(){
	// 	//可以连数据库等
	// 	$router=[
	// 		['uri'=>'/res','res'=>'//index/ces','domain'=>'127.0.0.1','site'=>'pwe','func'=>'rou1'],  //uri 匹配的规则 {字符串} [数字]  ,res 运行那个文件, domain:绑定域名，site 绑定入口目录
	// 		['uri'=>'/','res'=>'//index/ces','domain'=>'127.0.0.1','site'=>'','func'=>''],
	// 	];
	// 	return $router;
	// }
}
//默认路由过滤函数
function defRouter($router){
	return $router;
}